package com.coding.service.impl;

import com.coding.base.pojo.BaseModel;
import com.coding.base.pojo.PageQueryModel;
import com.coding.dao.PointDao;
import com.coding.pojo.Point;
import com.coding.service.PointService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @auther wangchenghao
 * @date 2020/9/19
 **/
@Service
public class PointImpl implements PointService {
   @Autowired
    PointDao pointDao;

    @Override
    public void getPoint(int user_id, PageQueryModel pageQueryModel, BaseModel baseModel) throws Exception {
        List<Point> pointList=pointDao.selectByUserId(user_id);
        PageInfo pageInfo = new PageInfo(pointList);
        pointList = pageInfo.getList();
        if (pointList.size() == 0) {
            if (pageInfo.getPageNum() > 1) {
                baseModel.setFailure("已经没有下一页了");
            } else {
                baseModel.setOther(2, "没有符合条件的积分详情");
            }
            return;
        }
        baseModel.setSucceed("查询成功，符合条件的积分详情共" + pointList.size() + "条", pointList);
    }

    @Override
    public void addPoint(int tasklist_id, int user_id, BaseModel baseModel) throws Exception {

    }
}
